//
//  SLHomeTitleButton.swift
//  0319iOSweiboDemo
//
//  Created by Tang on 16/3/24.
//  Copyright © 2016年 大天朝. All rights reserved.
//

import UIKit

class SLHomeTitleButton: UIButton {

    
    
    //便利构造函数.调用当前类的便利构造函数
   convenience init(title: String?, imageName: String) {
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        sizeToFit()
    }
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        //跳转图片的位置
        //1.将label移动到最左边
//        var frame = self.titleLabel!.frame
//        frame = CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height)
//        self.titleLabel?.frame = frame
        //Swift直接设置结构体里面的成员
       titleLabel!.frame.origin.x = 0
        
        //2.图片移动到label后面
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
        
    }
}
